package com.manbu.springcloud;

import com.manbu.springcloud.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.*;
import com.manbu.springcloud.pojo.Dept;

import java.util.List;

/**
 * @description:
 * @author: wanghan
 * @time: 2021/4/19 下午11:17
 */
@RestController
public class DeptController {
    @Autowired
    DeptService deptService;

    @Autowired
    DiscoveryClient clent; //得到具体的微服务配置信息
    @PostMapping("/dept/add")
    public boolean addDept(Dept dept) {
        return deptService.addDept(dept);
    }
    @GetMapping("/dept/get/{id}")
    @ResponseBody
    public Dept queryDeptById(@PathVariable("id") Long id) {
        return deptService.queryDeptById(id);
    }
    @GetMapping("/dept/list")
    @ResponseBody
    public List<Dept> queryAll() {
        return deptService.queryAll();
    }
    //注册进来的微服务获得一些信息
    public Object discovery(){
        //获得微服务列表的清单
        return clent.getServices();

    }
}
